package org.example.scoresystem_backen.common;

/**
 * 响应状态码枚举
 */
public enum ResultCode {
    
    // 成功
    SUCCESS(200, "操作成功"),
    
    // 客户端错误
    BAD_REQUEST(400, "请求参数错误"),
    UNAUTHORIZED(401, "未授权"),
    FORBIDDEN(403, "禁止访问"),
    NOT_FOUND(404, "资源不存在"),
    METHOD_NOT_ALLOWED(405, "请求方法不允许"),
    
    // 服务器错误
    ERROR(500, "系统内部错误"),
    
    // 业务错误码
    USER_NOT_FOUND(1001, "用户不存在"),
    USER_ALREADY_EXISTS(1002, "用户已存在"),
    PASSWORD_ERROR(1003, "密码错误"),
    LOGIN_FAILED(1004, "登录失败"),
    TOKEN_INVALID(1005, "令牌无效"),
    TOKEN_EXPIRED(1006, "令牌已过期"),
    
    STUDENT_NOT_FOUND(2001, "学生不存在"),
    STUDENT_ALREADY_EXISTS(2002, "学生已存在"),
    STUDENT_SNO_EXISTS(2003, "学号已存在"),
    
    CLASS_NOT_FOUND(3001, "班级不存在"),
    CLASS_ALREADY_EXISTS(3002, "班级已存在"),
    CLASS_HAS_STUDENTS(3003, "班级下还有学生，无法删除"),
    
    COURSE_NOT_FOUND(4001, "课程不存在"),
    COURSE_ALREADY_EXISTS(4002, "课程已存在"),
    COURSE_CODE_EXISTS(4003, "课程代码已存在"),
    COURSE_HAS_SCORES(4004, "课程下还有成绩记录，无法删除"),
    
    SCORE_NOT_FOUND(5001, "成绩不存在"),
    SCORE_ALREADY_EXISTS(5002, "该学生该课程成绩已存在"),
    SCORE_INVALID(5003, "成绩无效"),
    
    ADMIN_NOT_FOUND(6001, "管理员不存在"),
    ADMIN_ALREADY_EXISTS(6002, "管理员已存在"),
    
    VALIDATION_ERROR(7001, "数据验证失败"),
    DATA_INTEGRITY_ERROR(7002, "数据完整性错误"),
    OPERATION_NOT_ALLOWED(7003, "操作不被允许");
    
    private final Integer code;
    private final String message;
    
    ResultCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
    
    public Integer getCode() {
        return code;
    }
    
    public String getMessage() {
        return message;
    }
}
